@svizzle/utils/[any-boolean]-[object-any]

Methods

(static) findValueWith() → {function}

Source:
Since:
  • 0.12.0

Return a function expecting an object and returning the first of its values satisfying the provided predicate

Example
> findFirstOdd = findValueWith(x => x % 2 === 1);
> findFirstOdd({a: 2, b: 4, c: 3, d: 6, e: 7})
3
> findItem = findValueWith(isKeyValue(['max', 10]))
> findItem({a: {id: 'foo', min: 1, max: 2}, b: {id: 'bar', min: -1, max: 10}, c: {id: 'baz', min: -4, max: 10}})
{id: 'bar', min: -1, max: 10}
Parameters:
Type Description
predicate
Returns:
  • Object -> Any
Type
function